<template>
    <div  class="indextemplate" >
        <div class="indexdivtitle">我的应用</div>
        <div class="indexdiv">
            <MyIndexMode v-for="(item,i) in mymodeList" :key="i" :msg="item" @click="showmymode(item)" />
            <IndexMode v-for="(item,i) in modeList" :key="i" :msg="item" @click="show(item)" />
            <IndexMode :msg="configmode" @click="show(configmode)" />
        </div>
    </div>
</template>

<script>
    import IndexMode from '../components/IndexMode.vue'
    import MyIndexMode from '../components/MyIndexMode.vue'
    import {ref, reactive } from "vue";
    export default {
      name: 'Index',
      components: {
                IndexMode,
                MyIndexMode,
        },
        setup(){
            let modeList = reactive([])
            let mymodeList = reactive([])
            let configmode = reactive({
                modename:'设置',
                describe:'页面设置',
                logo:'icon-mianxingkeaijisuanji',
                path:'/config',
            })
            return{
                modeList,
                mymodeList,
                configmode
            }
        },
        async mounted(){
            pxmu.loading({
                msg: '正在加载', //loading信息 为空时不显示文本
                close: false, // 自动关闭 为false时可在业务完成后调用 pxmu.closeload();手动关闭
                inscroll: true, //模态 不可点击和滚动
            })
            let res = await this.axios.post("/getmodelist",{})
            //手动关闭
            pxmu.closeload(100);//延时100毫秒关闭 默认0
            console.log(res)
            //this.mymodeList.splice(0, this.mymodeList.length)
            for (let index = 0; index < res.data.mymodeList.length; index++) {
                const element = res.data.mymodeList[index];
                this.mymodeList.push(element)
            }
            this.modeList.splice(0, this.modeList.length)
            for (let index = 0; index < res.data.modeList.length; index++) {
                this.modeList.push(res.data.modeList[index])
            }
        },
      methods: {
        show(item) {
            let routeData = this.$router.resolve(item.path)
            window.open(routeData.href, '_blank')
        },
        showmymode(item) {
            window.open(item.path, '_blank')
        }
      }
    }
</script>
<style>
    
</style>